﻿using BCCommon;
using BCDto.TMS.MarketingCoupon.MarketingCouponReceive;
using BCService.TMS.MarketingCoupon.MarketingCouponReceive;
using Microsoft.AspNetCore.Mvc;

namespace BCTMSRESTful.Controllers.Management.TMS.MarketingCoupon
{
    /// <summary>
    /// 优惠券领取记录
    /// </summary>
    [Route("api/v1/sim/[controller]")]
    [ApiExplorerSettings(GroupName = "TMSAdmin")]
    public class MarketingCouponReceiveController : ManagementBaseController
    {
        private readonly IMarketingCouponReceiveService marketingCouponReceiveService;
        public MarketingCouponReceiveController(
            IMarketingCouponReceiveService marketingCouponReceiveService)
        {
            this.marketingCouponReceiveService = marketingCouponReceiveService;
        }


        /// <summary>
        /// 获取优惠券领取详情
        /// </summary>
        /// <param name="marketingCouponReceiveId">优惠券领取记录id</param>
        /// <returns></returns>
        [HttpGet("[action]/{marketing_coupon_receive_id}")]
        [ProducesResponseType(typeof(MarketingCouponReceiveDto), 200)]
        public IActionResult GetReceiveInfo(
            [FromRoute(Name = "marketing_coupon_receive_id")] long marketingCouponReceiveId
            )
        {
            var result = this.marketingCouponReceiveService.GetInfo(marketingCouponReceiveId);
            return this.Ok(result);
        }

        /// <summary>
        /// 获取优惠券领取记录分页
        /// </summary>
        /// <param name="marketingCouponTypeId">优惠券类型id</param>
        /// <param name="userId">用户id</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<MarketingCouponReceiveDto>), 200)]
        public IActionResult ReceiveQuery(
            [FromQuery(Name = "marketing_coupon_type_id")] long? marketingCouponTypeId,
            [FromQuery(Name = "user_id")] long? userId,
            [FromQuery(Name = "page_index")] int pageIndex = 1,
            [FromQuery(Name = "page_size")] int pageSize = 10)
        {
            var result = this.marketingCouponReceiveService.Query(marketingCouponTypeId, userId, null, null, pageIndex, pageSize);
            return this.Ok(result);
        }

    }
}
